<div class="container">
    
    <?php $att = array('class' => 'form-horizontal', 'role' => 'form', 'id' => 'postForm', 'onsubmit' => 'return postForm()'); echo form_open('', $att);?>
    <input type="hidden" name="id" id="id" value="<?php echo $id;?>" />
    <div class="col-md-6">
        <div class="row">
            <div class="col-md-12">
              <div class="panel">
                <div class="panel-heading">
                  <div class="panel-title"> <span class="glyphicon glyphicon-pencil"></span> Sửa slide </div>
                </div>
                <div class="panel-body">
                    <?php if(isset($result) || validation_errors()):?>
                    <div class="alert alert-danger alert-dismissable">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                             <?php if(isset($result)){echo $result;}?>
                            <?php echo validation_errors(); ?>
                    </div>
                    <?php endif;?>
                    <div class="form-group">
                      <label for="inputStandard" class="col-lg-2 control-label">Tên slide</label>
                      <div class="col-lg-10">
                        <input type="text" id="namePro" name="namePro" class="form-control" value="<?php echo $data->title?>" placeholder="Tên slide">
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="inputPassword" class="col-lg-2 control-label">Link liên kết</label>
                      <div class="col-lg-10">
                        <input type="text" class="form-control" id="link" name="link" value="<?php echo $data->link?>" placeholder="Link liên kết">
                      </div>
                    </div>
                    
                    
                    <div class="form-group">
                      <label for="inputPassword" class="col-lg-2 control-label">Giới thiệu</label>
                      <div class="col-lg-10">
                        <textarea class="form-control text-field-alt margin-bottom-lg" rows="2" id="summernote" name="content" placeholder=""><?php echo $data->brief?></textarea>
                      </div>
                    </div>
                </div>
              </div>
            </div>
        </div>
    </div>
    <div class="col-md-3-3">
        <div class="row">
            <div class="col-md-12">
                 <div class="panel">
                    <div class="panel-heading">
                      <div class="panel-title">Hành động</div>
                    </div>
                    <div class="panel-body">
                      <div class="form-group">
                          <div class="col-lg-10" style="width: 100%;">
                           <label for="img" style="cursor: pointer;width: 100% !important;">
                            <div class="console-btn">
                            
                              <div class="console-icon divider-right"> <span class="glyphicon glyphicon-open"></span> </div>
                              <div class="console-text">
                               
                                <div class="console-subtitle">
                                Ảnh Slide
                                </div>
                                <div class="console-title">
                                <input type="file" name="img" id="img" value="" onchange="convertimg()" style="display: none;" />
                                <input type="text" name="img_hidden" id="img_hidden" value="" style="display: none;" />
                                
                                <label for="img" style="position: absolute;cursor: pointer">Chọn ảnh</label>
                                </div>
                              </div>
                              
                              <div class="clearfix"></div>
                              <img id="img_show" src="<?php echo $baseurl.$data->img?>" style="width: 100%;" />
                            </div>
                            </label>
                            
                            <button type="submit" class="btn btn-info btn-gradient btn-sm">Lưu lại</button>
                            <button type="button" class="btn btn-default btn-gradient btn-sm" onclick="window.location='<?php echo $baseurl.'manage/slide.html'?>'">Hủy bỏ</button>
                          </div>
                        </div>
                    </div>  
                 </div>
            </div>
        </div>
    </div>
    </form>
</div>
<script>
function convertimg()
{
    var chose = chose;
    var filesSelected = document.getElementById("img").files;
    if (filesSelected.length > 0)
    {
        var fileToLoad = filesSelected[0];

        var fileReader = new FileReader();

        fileReader.onload = function(fileLoadedEvent) 
        {
            var textAreaFileContents = document.getElementById
            (
                "textAreaFileContents"
                );
            $("#img_hidden").attr('value', fileLoadedEvent.target.result);
            $("#img_show").attr('src', fileLoadedEvent.target.result);
            
            
        };

        fileReader.readAsDataURL(fileToLoad);
    }
}
function postForm() 
{
	var content = $('textarea[name="content"]').html($('#summernote').code());
}
</script>